package com.saikuo.service.controller;

import com.saikuo.service.api.ApiResultModel;
import com.saikuo.service.service.IStoreInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by shanchangyu on 16/10/13.
 */
@Api(value = "药店信息相关接口", description = "药店信息(地理位置)等")
@RestController
@RequestMapping("/store")
public class StoreInfoController {
    @Autowired
    private IStoreInfoService storeInfoService;

    @ApiOperation(value = "根据药店编号查询药店信息")
    @RequestMapping(value = "/getStoreInfoByStoreCode", method = RequestMethod.GET)
    public ApiResultModel getStoreInfoByStoreCode(@RequestParam String storeCode) {
        return storeInfoService.getStoreInfoByStoreCode(storeCode);
    }

    @ApiOperation(value = "修订药店信息")
    @RequestMapping(value = "/updateStoreInfo", method = RequestMethod.POST)
    public ApiResultModel updateStoreInfo(@RequestParam String storeCode,
            @RequestParam String name,
                                   @RequestParam String address,
                                   @RequestParam Double lat,@RequestParam Double lng,@RequestParam String cityCode,@RequestParam String areaCode,@RequestParam String mobile,@RequestParam String phone) {
        return storeInfoService.updateStoreInfo(storeCode,name, address, lat, lng, cityCode, areaCode, mobile,phone);
    }


    @ApiOperation(value = "根据用户定位获取周边5km内最近的一家药店")
    @RequestMapping(value = "/getStoresByUserLocation", method = RequestMethod.GET)
    public ApiResultModel getStoresByUserLocation(@RequestParam Double lat,@RequestParam Double lng,@RequestParam String cityCode,@RequestParam String areaCode) {
        return storeInfoService.getStoresByUserLocation(lat, lng, cityCode, areaCode);
    }

}
